Skip to content

examples: capability-dependent demo library + app with both negative tests (#5957) - #6237

Merged
dezren39 merged 1 commit into
mainfrom
queue/10533-5957-demo-capability-library
Nov 5, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/10533-5957-demo-capability-library

Conversation

@developing-today

@developing-today developing-today Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Implements #5957 (queue task 10533): a demo library + app demonstrating the Roc library import model for worlds, where the library depends on a platform capability.

What

  • pkgs/id/examples/roc-cap-demo/lib/ — the demo library, a Roc package. Greeter.roc greets world participants by name; the names live in the world records, so the library issues a records.read capability request through the platform's RocCap protocol helpers. It is therefore not pure: it only works on a platform providing that capability. All protocol handling (issuing, announcing in wants, routing results by id, retiring requests, session snapshot/restore) lives in the library.
  • pkgs/id/examples/roc-cap-demo/main.roc — the demo app importing the library via the package; it only decodes host events and renders greetings.
  • pkgs/id/examples/roc-world/platform-no-caps.roc — a reduced platform fixture: platform.roc with RocCap removed from exposes/imports.

Both negative tests (acceptance criteria)

Wired into scripts/roc-test.sh (the roc-test just recipe / flake check) via roc-cap-demo-test.sh, so they run in the normal test flow:

  • Negative A (capability not on the platform): main-missing-cap.roc — the same app + library bound to the reduced platform — must fail to compile, and the failure must name the missing pf.RocCap module (asserted, not just any failure).
  • Negative B (platform used wrong): main-wrong-usage.roc calls RocCap.schedule_at_request with a wrong signature — must fail with a type mismatch at that call (asserted).

The positive path (library expect tests + app typecheck) runs first in the same script.

Verification

  • Laptop (roc nightly-2026-10-06): full bash scripts/roc-test.sh passes — 108 library expects (incl. 5 new Greeter expects; mutation-checked: breaking one expect fails the run), app checks clean, both negative tests fail for the pinned reasons.
  • CI (pinned roc via the roc-test flake check) is the verification of record per repo policy.

Note: lib-no-caps/Greeter.roc is a byte-identical copy of lib/Greeter.roc (Roc package modules cannot be symlinked from outside the package root); the test script fails if the copies drift. The harness is named roc-cap-demo-test.sh because pkgs/id/.gitignore ignores test.*.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…tests (#5957)

Greeter (pkgs/id/examples/roc-cap-demo/lib) is a Roc package whose
library depends on the platform records.read capability via RocCap;
main.roc is the demo app importing it. Negative tests: the same
app+library against the reduced platform-no-caps.roc must fail over
the missing pf.RocCap (A), and a wrong-signature schedule_at_request
call must fail with a type mismatch (B). Both are wired into
scripts/roc-test.sh so they run in the roc-test flake check.
@developing-today
developing-today Bot requested review from a team and dezren39 as code owners November 5, 2026 13:52
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a59bcde9-7aeb-46fc-be93-a16ffa6dddcd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant